package conf

import (
	"fmt"
	"github.com/spf13/viper"
)

type AppConfig struct {
	MysqlConfig
}

type MysqlConfig struct {
	User     string
	Password string
	Host     string
	Port     int
	Database string
}

var Con AppConfig

func Init() {
	viper.SetConfigFile("./conf/config.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		fmt.Println("读取配置文件失败")
		return
	}
	err = viper.Unmarshal(&Con)
	if err != nil {
		fmt.Println("解析配置文件失败")
		return
	}
	fmt.Println("解析配置文件成功")
}
